$(function () {
	$('#start').on('click', function (event) {
		var _this = $(this);
		event.stopPropagation();
		if (_this.hasClass('disabled')) return;
		_this.addClass('loading');
		$.get(window.location.href + '/start')
            .done(function (data) {
                _this.removeClass('loading');
				_this.addClass('disabled');
				$('#stop').removeClass('disabled');
				console.log('已经开始测量');
            }).
            fail(function (para) {
                _this.removeClass('loading');
				console.log('测量发生错误');
            });
	});

	$('#stop').on('click', function (event) {
		event.stopPropagation();
		var _this = $(this);
		if (_this.hasClass('disabled')) return;
		_this.addClass('loading');
		$.get(window.location.href + '/stop')
            .done(function (data) {
                _this.removeClass('loading');
				console.log('已经停止测量');
				_this.addClass('disabled');
				$('#start').removeClass('disabled');
            }).
            fail(function (para) {
                _this.removeClass('loading');
				console.log('停止测量发生错误');
            });
	});
});